import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../config/global_config.dart';
import 'logic.dart';

class MainTabbarPage extends StatelessWidget {
  MainTabbarPage({Key? key}) : super(key: key);

  final logic = Get.put(MainTabbarLogic());

  @override
  Widget build(BuildContext context) {
    final iconW = 24.w;

    return Scaffold(
      backgroundColor: Colors.white,
      body: PageView(
        physics: const NeverScrollableScrollPhysics(),

        controller: logic.pageController,
        children: logic.pageList,
      ),
      bottomNavigationBar: Obx(() {
        return CupertinoTabBar(
          backgroundColor: Colors.white,
          currentIndex: logic.tabbarIndex.value,
          activeColor: kMainColor,
          inactiveColor: kInactiveColor,
          onTap: logic.jumpPage,
          items:
          logic.tabbarList.map((data) {
            return BottomNavigationBarItem(
              icon: Image.asset(
                width: iconW,
                height: iconW,
                data['icon']!,
                gaplessPlayback: true,
              ),
              label: data['label'],
              activeIcon: Image.asset(
                width: iconW,
                height: iconW,
                data['activeIcon']!,
                gaplessPlayback: true,
              ),
            );
          }).toList(),
        );
      }),
    );
  }
}
